package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.WmStatisticsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/api/v1/statistics")
public class WmStatisticsController {

    @Autowired
    private WmStatisticsService wmStatisticsService;


    /**
     * 自媒体端,图文统计数量统计
     * @return
     */
    @GetMapping("/newsDimension")
    public ResponseResult dimension(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate){
        return wmStatisticsService.dimension(beginDate, endDate);
    }


    /**
     * 图文统计,显示查询到的数据
     * @param beginDate
     * @param endDate
     * @param page
     * @param size
     * @return
     */
    @GetMapping("newsPage")
    public ResponseResult newPage(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate,
                                  @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
                                  Integer page, Integer size){
        return wmStatisticsService.newPage(beginDate,endDate,page,size);
    }

}
